﻿// ZCBHandwrittenDataStructure.cpp: 定义应用程序的入口点。
//

#include "ZCBHandwrittenDataStructure.h"
#include "./zcb_string.h"
#include "./zcb_vector.h"
using namespace std;

struct test
{
	int a;
	test* b = nullptr;
	test(){ std::cout << "create test\n"; }

	test(test&& x) {};

	test(int&& x)
		:a(x)
	{
		std::cout << "create test with rvalue\n";
	}

	~test()
	{
		std::cout << "destroy test\n";
	}
};

struct sub_test: public test
{

};

template<typename ty>
void pri(ty x)
{
	std::cout << x;
}
class Solution {
public:

    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };

    vector<int> topKFrequent(vector<int>& nums, int k) {

        std::map<int, int> m;
        typedef std::map<int, int, compare> mmap;
        const int size = nums.size();
        std::vector<int> res;
        res.resize(k);
        for (int i = 0; i < size; ++i)
        {
            if (!m.count(nums[i]))
            {
                m.insert(mmap::value_type(nums[i], 1));
            }
            else
            {
                ++m[nums[i]];
            }

        }

        std::vector<std::pair<int, int>> myvec(m.begin(), m.end());

        std::sort(myvec.begin(), myvec.end(), [](const auto& l, const auto& r) {
            return l.second > r.second;
            });

        for (int i = 0; i < myvec.size(); ++i)
        {
            if (!k)break;
            res.push_back(myvec[i].first);
            --k;
        }
        return res;
    }
};
int main()
{
	std::map<int, char> m;
    
 	if (!m.count(0))
	{
		m.insert(std::pair<int, char>(0, 'a'));
		m.insert(std::pair<int, char>(2, 'b'));
		m.insert(std::pair<int, char>(1, 'a'));
		m[3] = 'c';
	}

	for (std::map<int, char>::iterator iter = m.begin(); iter != m.end(); ++iter)
	{
		std::cout << iter->first << ':' << iter->second << std::endl;
	}

	typedef std::unordered_map<int, int> U_2i_map;
	std::unordered_map<int, int> _U_map;
	
	_U_map.insert(U_2i_map::value_type(1, 2));

	std::cout << _U_map[1];
	return 0;
}

//_CONSTEXPR20 basic_string(_In_z_ const _Elem* const _Ptr) : _Mypair(_Zero_then_variadic_args_t{}) {
//	_Construct<_Construct_strategy::_From_ptr>(_Ptr, _Convert_size<size_type>(_Traits::length(_Ptr)));
//}
